﻿using NeXus.BIMBase.Core;
using NeXus.p3d;
using System.Collections.Generic;

namespace checc_baseTools
{
    public class Spring
    {
        ///// <summary>
        ///// 绘制螺旋线
        ///// </summary>
        ///// <param name="radius">螺旋线半径</param>
        ///// <param name="height">螺旋线高度</param>
        ///// <param name="pitch">螺距</param>
        //public static void SpiralLine(double radius, double height, double pitch)
        //{
        //    List<GePoint3d> points = new List<GePoint3d>();
        //    List<GePoint3d> allPoints = new List<GePoint3d>();

        //    double angle = 0.72;

        //    //求平面圆
        //    for (int i = 0; i < 360 / angle; i++)
        //    {
        //        GePoint3d p = Helper.Rotation(new GePoint3d(0, 0, 0), new GePoint3d(radius, 0, 0), radius, angle * i);
        //        GePoint3d point3D = new GePoint3d(p.x, p.y, p.z);
        //        points.Add(point3D);
        //        allPoints.Add(point3D);
        //    }

        //    //求弹簧的点
        //    for (int i = 0; i < height / pitch; i++)
        //    {
        //        for (int j = 0; j < points.Count; j++)
        //        {
        //            if (height % pitch != 0 && i == (int)(height / pitch))
        //            {
        //                int n = (int)(height / pitch);
        //                double num = ((height / pitch) - n) * pitch;

        //                if (j == num / (pitch / (360 / angle)))
        //                {
        //                    for (int z = 0; z < allPoints.Count - 1; z++)
        //                    {
        //                        Element_chain.Thread(allPoints[z], allPoints[z + 1]);
        //                    }
        //                    return;
        //                }

        //                GePoint3d point = new GePoint3d(points[j].x, points[j].y, points[j].z + (pitch / (360 / angle)) * (j + 1) + i * pitch);
        //                allPoints.Add(point);
        //            }
        //            else
        //            {
        //                GePoint3d point3D = new GePoint3d(points[j].x, points[j].y, points[j].z + (pitch / (360 / angle)) * (j + 1) + i * pitch);
        //                allPoints.Add(point3D);
        //            }

        //        }
        //    }

        //    for (int i = 0; i < 360 / angle; i++)
        //    {
        //        GePoint3d p = Helper.Rotation(new GePoint3d(0, 0, 0), new GePoint3d(radius, 0, 0), radius, angle * i);
        //        GePoint3d point3D = new GePoint3d(p.x, p.y, height);
        //        allPoints.Add(point3D);
        //    }

        //    //Element_chain.LoftingLine(allPoints, 3, 100);

        //    for (int i = 0; i < allPoints.Count - 1; i++)
        //    {
        //        Element_chain.Thread(allPoints[i], allPoints[i + 1]);
        //    }

        //}

        ///// <summary>
        ///// 获取绘制螺旋线的点集合
        ///// </summary>
        ///// <param name="radius">螺旋线半径</param>
        ///// <param name="height">螺旋线高度</param>
        ///// <param name="pitch">螺距</param>
        //public static List<GePoint3d> getSpiralLine(double radius, double height, double pitch)
        //{
        //    IBPProjectManager iBPProjectManager = BPApplication.getInstance().getProjectManager();
        //    BPModelBase bPModelBase = iBPProjectManager.getActiveModel();

        //    List<GePoint3d> points = new List<GePoint3d>();
        //    List<GePoint3d> allPoints = new List<GePoint3d>();

        //    double angle = 1;

        //    //求平面圆
        //    for (int i = 0; i < 360 / angle; i++)
        //    {
        //        GePoint3d p = Helper.Rotation(new GePoint3d(0, 0, 0), new GePoint3d(radius, 0, 0), radius, angle * i);
        //        GePoint3d point3D = new GePoint3d(p.x, p.y, p.z);
        //        points.Add(point3D);
        //        allPoints.Add(point3D);
        //    }

        //    //求弹簧的点
        //    for (int i = 0; i < height / pitch; i++)
        //    {
        //        for (int j = 0; j < points.Count; j++)
        //        {
        //            if (height % pitch != 0 && i == (int)(height / pitch))
        //            {
        //                int n = (int)(height / pitch);
        //                double num = ((height / pitch) - n) * pitch;

        //                if (j == num / (pitch / (360 / angle)))
        //                {
        //                    for (int z = 0; z < allPoints.Count - 1; z++)
        //                    {
        //                        Element_chain.Thread(allPoints[z], allPoints[z + 1]);
        //                    }
        //                    return allPoints;
        //                }

        //                GePoint3d point = new GePoint3d(points[j].x, points[j].y, points[j].z + (pitch / (360 / angle)) * (j + 1) + i * pitch);
        //                allPoints.Add(point);
        //            }
        //            else
        //            {
        //                GePoint3d point3D = new GePoint3d(points[j].x, points[j].y, points[j].z + (pitch / (360 / angle)) * (j + 1) + i * pitch);
        //                allPoints.Add(point3D);
        //            }

        //        }
        //    }

        //    for (int i = 0; i < 360 / angle; i++)
        //    {
        //        GePoint3d p = Helper.Rotation(new GePoint3d(0, 0, 0), new GePoint3d(radius, 0, 0), radius, angle * i);
        //        GePoint3d point3D = new GePoint3d(p.x, p.y, height);
        //        allPoints.Add(point3D);
        //    }

        //    //Element_chain.LoftingLine(allPoints, 3, 100);

        //    for (int i = 0; i < allPoints.Count - 1; i++)
        //    {
        //        Element_chain.Thread(allPoints[i], allPoints[i + 1]);
        //    }

        //    return allPoints;
        //}

        ///// <summary>
        ///// 画弹簧实体
        ///// </summary>
        ///// <param name="points">弹簧的点集</param>
        ///// <returns></returns>
        //public static IGeSolidBase ReleaseBody(List<GePoint3d> points)
        //{
        //    IBPProjectManager iBPProjectManager = BPApplication.getInstance().getProjectManager();
        //    BPModelBase bPModelBase = iBPProjectManager.getActiveModel();


        //    List<GeCurveArray> curves = new List<GeCurveArray>();

        //    for (int i = 0; i < points.Count - 1; i++)
        //    {
        //        GeVec3d geVec3D = new GeVec3d(points[i + 1].x - points[i].x, points[i + 1].y - points[i].y, points[i + 1].z - points[i].z);
        //        GeEllipse3d arcSec = GeEllipse3d.createByCircle(points[i], geVec3D, 100);
        //        GeCurveArray section = GeCurveArray.createEllipseCurve(arcSec, GeCurveArray.BoundaryType.Outer, false);
        //        curves.Add(section);
        //    }
        //    GeRuledSweepInfo sweepInfo = new GeRuledSweepInfo(curves, true);
        //    IGeSolidBase gesoild = Element_solid.SweptBody(sweepInfo);
        //    return gesoild;

        //}


    }
}
